{include file="common/header"}

<script type="text/javascript" charset="utf-8" src="__CDN__/assets/js/index/ue/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__CDN__/assets/js/index/ue/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__CDN__/assets/js/index/ue/lang/zh-cn/zh-cn.js"></script>
<div class="container fatieandedit">

	<p class="f">发帖</p>

	<form action="/index/user/addArticle.html" method="POST" enctype="multipart/form-data" id="form1">
		<div class="fatieandedit-list biaoti">
			<div class="fatie-edit-left">
				<label>标题：</label>
			</div>
			<div class="fatie-edit-right bankuai">
				<input type="text" name="title" placeholder="标题">
			</div>
		</div>
		<div class="fatieandedit-list">
			<div class="fatie-edit-left">
				<label>内容：</label>
			</div>
			<div class="fatie-edit-right editor">
				<textarea id="editor" name="content" style="width:990px;height:500px;"></textarea>
			</div>
		</div>

		<div class="fatieandedit-list qiepian">
			<div class="fatie-edit-left">
				<label>附件：</label>
			</div>
			<div class="fatie-edit-right ">
				<input type="text" name="qiepian[0][title]" placeholder="附件名称">
				<label for="qiepian4" class="filebtn">上传文件</label>
				<input type="file" name="qiepian[0][file]" id="qiepian0" onchange="showPreview(this)" class="myfile" accept="a">
				<span></span>
				<a class='deleteImg' href='javascript:;'>删除附件</a>
				<p class="progress1">
					<a id="Progress"></a>
				</p>
			</div>
		</div>
		<div class="fatieandedit-list qiepian">
			<div class="fatie-edit-left">
				<label>附件：</label>
			</div>
			<div class="fatie-edit-right ">
				<input type="text" name="qiepian[1][title]" placeholder="附件名称">
				<label for="qiepian1" class="filebtn">上传文件</label>
				<input type="file" name="qiepian[1][file]" id="qiepian1" onchange="showPreview(this)" class="myfile" accept="application/vnd.ms-excel,application/msword,application/pdf,application/vnd.ms-powerpoint">
				<span></span>
				<a class='deleteImg' href='javascript:;'>删除附件</a>
				<p class="progress1">
					<a id="Progress"></a>
				</p>
			</div>
		</div>
		<div class="fatieandedit-list qiepian">
			<div class="fatie-edit-left">
				<label>附件：</label>
			</div>
			<div class="fatie-edit-right ">
				<input type="text" name="qiepian[2][title]" placeholder="附件名称">
				<label for="qiepian2" class="filebtn">上传文件</label>
				<input type="file" name="qiepian[2][file]" id="qiepian2" onchange="showPreview(this)" class="myfile" accept="application/vnd.ms-excel,application/msword,application/pdf,application/vnd.ms-powerpoint">
				<span></span>
				<a class='deleteImg' href='javascript:;'>删除附件</a>
				<p class="progress1">
					<a id="Progress"></a>
				</p>
			</div>
		</div>
		<div class="fatieandedit-list qiepian">
			<div class="fatie-edit-left">
				<label>附件：</label>
			</div>
			<div class="fatie-edit-right ">
				<input type="text" name="qiepian[3][title]" placeholder="附件名称">
				<label for="qiepian3" class="filebtn">上传文件</label>
				<input type="file" name="qiepian[3][file]" id="qiepian3" onchange="showPreview(this)" class="myfile" accept="application/vnd.ms-excel,application/msword,application/pdf,application/vnd.ms-powerpoint">
				<span></span>
				<a class='deleteImg' href='javascript:;'>删除附件</a>
				<p class="progress1">
					<a id="Progress"></a>
				</p>
			</div>
		</div>
		<div class="fatieandedit-list qiepian">
			<div class="fatie-edit-left">
				<label>附件：</label>
			</div>
			<div class="fatie-edit-right ">
				<input type="text" name="qiepian[4][title]" placeholder="附件名称">
				<label for="qiepian4" class="filebtn">上传文件</label>
				<input type="file" name="qiepian[4][file]" id="qiepian4" onchange="showPreview(this)" class="myfile" accept="application/vnd.ms-excel,application/msword,application/pdf,application/vnd.ms-powerpoint">
				<span></span>
				<a class='deleteImg' href='javascript:;'>删除附件</a>
				<p class="progress1">
					<a id="Progress"></a>
				</p>
			</div>
		</div>
	</form>

	<div class="fatieandedit-list  tianjiaqiepian" style="text-align: left;padding-left: 80px;cursor: pointer;text-decoration: none;">
		<a>点击添加附件框</a>
	</div>

	<div class="fatieandedit-list ">

		<div class="fatie-edit-left">

			<label style="visibility: hidden;">附件：</label>

		</div>

		<div class="fatie-edit-right ">
			<input type="checkbox" checked name="ag" placeholder="附件名称" id="banquansm" form="form1">
			<p> 版权声明<label for="banquansm" class="banquansm">这是我的原创内容，我已阅读并同意<a href="">《智识原创声明》</a></label>
				<input type="submit" name="" class="bangquansm-btn" value="发表" form="form1">
		</div>
		    <div style="clear: both;"></div>
            <p id="wrong" style="text-align: center;"></p>
	</div>

</div>

<script>
	function showPreview(source) {
		var arrs = $(source).val().split('\\');
		var filename = arrs[arrs.length - 1];
		$(source).next().html(filename);
		var file = source.files[0];
		var total = file.size;
		if(window.FileReader) {
			var fr = new FileReader();
			fr.onprogress = function(e) { // $(".progress1").show();
				$("#Progress").html('文件上传中');
			}
			//$("#Progress").html((e.loaded/total)*100) };
			fr.onabort = function() {
				alert("文件上传中断,请重试")
			};
			fr.onerror = function() {
				alert("文件上传出错，请重试")
			};
			fr.onload = function() {
				$(".progress1").hide();
				//alert("文件上传成功")
			};
			fr.readAsDataURL(file);
		}
	}
</script>

<!-- 底部样式开始           -->
{include file="common/login"}
{include file="common/footer"}
<script type="text/javascript">
	var ue = UE.getEditor('editor');
</script>

<!-- 添加附件框功能 -->

<script type="text/javascript">
	// $('.deleteImg').live('click',function(){

	//   //单击后获取input的id

	//      var imageInput = $(this).siblings('input[type=file]');

	//      console.log(imageInput);

	// })

	$("body").on('click', '.deleteImg', function() {

		var images = $(this).siblings('input[type=file]');

		images.parent().parent().remove();

	});

$('input[type=submit]').click(function() {
	var ed = (UE.getEditor('editor').getContent());
	// return false;
		var gouxuan = $('input[type=checkbox]').is(':checked');
		if(!gouxuan){
		$('#wrong').html('必须勾选同意按钮才可以发布文章')
		return false;
		}     
		if ($('input[name=title]').val() == ""){
		$('#wrong').html('文章标题不能为空');
		$('input[name=title]').focus();
		return false;
		}

		if(ed ==""){
		$('#wrong').html('文章内容不能为空');
        UE.getEditor('editor').focus();
		return false;
	}

})


// 切片添加
$('.tianjiaqiepian').click(function() {

	time = (new Date()).valueOf();

	var str = " <div class='fatieandedit-list qiepian'><div class='fatie-edit-left'><label>附件：</label></div><div class='fatie-edit-right'><input type='text' name='qiepian' placeholder='附件名称' style='margin-right:4px;'><label for='" + time + "' class='filebtn' style='margin-right:4px;'>上传文件</label><input type='file' name='qiepian' id='" + time + "' onchange='showPreview(this)'  accept=\"application/vnd.ms-excel,application/msword,application/pdf,application/vnd.ms-powerpoint\"><span ></span><a href='javascript:;' class='deleteImg' >删除附件</a></div></div>";

	$('#form1').append(str);

})
</script>